﻿<Window x:Class="Reckoning.MainWindow"        
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:l="clr-namespace:Reckoning"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:p="clr-namespace:Reckoning.Properties"
        Title="{x:Static p:Resources.LabelTitle}"
        MinWidth="480" MinHeight="480"        
        Height="600" Width="600"        
        Icon="/Reckoning;component/Resources/abacus.jpg"
        FocusManager.FocusedElement="{Binding ElementName=textBoxFile}">

    <Window.Resources>
        <BooleanToVisibilityConverter x:Key="bvc" />
    </Window.Resources>

    <ScrollViewer Name="scrollViewerMain" VerticalScrollBarVisibility="Auto">        
    
        <Grid Name="gridMain"           
              Margin="6,6,6,6">        
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />                     
                <RowDefinition Height="Auto" />
                <RowDefinition Height="*" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition />
            </Grid.ColumnDefinitions>


            <!-- Content -->
            <Grid Name="gridContent"                   
                  Grid.Row="0" 
                  Margin="6,6,6,6">            
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="*" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>

                <Label Name="labelInstructions"
                       Grid.Row="0"
                       Content="{x:Static p:Resources.LabelInstructions}" 
                       FontWeight="Bold" 
                       Margin="0,6,0,6" />
                
                <Grid Row="1"                      
                      Margin="0,6,0,6">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="Auto"/>
                    </Grid.ColumnDefinitions>

                    <Label Name="labelLoadFromFile"                                
                           Grid.Column="0"
                           Content="{x:Static p:Resources.LabelLoadFromFile}" 
                           HorizontalAlignment="Left" /> 
                    
                    <TextBox Name="textBoxFile"
                             Grid.Column="1"
                             HorizontalAlignment="Stretch" VerticalAlignment="Top"
                             Text="{Binding File}" 
                             Margin="6,0,6,0"
                             ToolTip="{x:Static p:Resources.ToolTipFile}"
                             TabIndex="0"/>
                    
                    <Button Name="buttonFile" 
                            Content="{x:Static p:Resources.LabelBrowse}" 
                            Grid.Column="2"
                            HorizontalAlignment="Right" VerticalAlignment="Top"                        
                            Padding="6,2,6,2" 
                            ToolTip="{x:Static p:Resources.ToolTipBrowse}"
                            Click="ButtonFile_Click"                             
                            TabIndex="1" />
                </Grid>

                <TextBlock Name="textBlockOverflow"                        
                        Grid.Row="2" 
                        Text="{x:Static p:Resources.LabelOverflow}" 
                        FontStyle="Italic" 
                        Margin="6,6,6,6"
                        TextWrapping="Wrap" 
                        Visibility="{Binding Overflow, Converter={StaticResource bvc}}"/>

                <TextBox Name="textBoxContent" 
                         Grid.Row="3" Grid.ColumnSpan="2"
                         Text="{Binding Content}" AcceptsReturn="True" 
                         IsReadOnly="{Binding Overflow}"
                         ToolTip="{x:Static p:Resources.ToolTipContent}"
                         MinHeight="100" MaxHeight="200"
                         HorizontalAlignment="Stretch" VerticalAlignment="Stretch" 
                         Margin="0,6,0,6" 
                         VerticalScrollBarVisibility="Auto"                          
                         TabIndex="2" DataContext="{Binding}" />

                <Button Name="ClearContent"
                        Content="{x:Static p:Resources.LabelClearContent}" 
                        ToolTip="{x:Static p:Resources.ToolTipClear}"
                        Grid.Row="4" Grid.ColumnSpan="2"
                        HorizontalAlignment="Right"                        
                        Margin="0,6,0,6" Padding="6,2,6,2"
                        Click="ButtonClearContent_Click"
                        TabIndex="3" />
            </Grid>
            <!-- Content -->

            <Expander Header="{x:Static p:Resources.LabelOptions}"
                      Grid.Row="1" 
                      KeyboardNavigation.TabNavigation="Local"
                      TabIndex="4"
                      Margin="0,6,0,6">

                <Grid Name="gridOptions"  
                      Grid.Row="0"                  
                      Margin="6,6,6,6">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="*" />
                    </Grid.RowDefinitions>

                    <!-- Processing Criteria -->
                    <Grid Name="gridProcCriteria"  
                          Grid.Row="0"
                          Margin="6,6,6,6">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>

                        <!-- Section Header -->
                        <Label Name="LabelProcessCriteria"
                                Content="{x:Static p:Resources.LabelProcessCriteria}"                           
                                Grid.Row="0" 
                                Margin="6,6,0,6" 
                                FontStyle="Italic" />

                        <!-- Stem -->
                        <CheckBox Name="checkBoxStem" 
                                    IsChecked="{Binding DoStemming}" 
                                    Content="{x:Static p:Resources.LabelPerformStemming}" 
                                    ToolTip="{x:Static p:Resources.ToolTipStemming}"                      
                                    Grid.Row="1" 
                                    Margin="24,6,0,6" 
                                    TabIndex="5" />

                        <!-- Stop -->
                        <CheckBox Name="checkBoxStop" 
                                    IsChecked="{Binding UseStopWords}"
                                    Content="{x:Static p:Resources.LabelOmitStopWords}" 
                                    ToolTip="{x:Static p:Resources.ToolTipStopWords}" 
                                    Grid.Row="2" Grid.Column="0"
                                    Margin="24,6,6,0" 
                                    TabIndex="6" />
                        
                        <Button Name="EditStopWords"
                                Content="{x:Static p:Resources.LabelEditStopWords}"
                                ToolTip="{x:Static p:Resources.ToolTipEditStopWords}"
                                Grid.Row="2" Grid.Column="1"
                                HorizontalAlignment="Right"
                                Padding="6,2,6,2" 
                                Margin="6,0,6,0" 
                                Command="{Binding EditStopWordsCommand}"
                                TabIndex="7"/>

                    </Grid>
                    <!-- Processing Criteria -->


                    <!-- Output Criteria -->
                    <Grid Name="gridOutputCriteria"               
                          Grid.Row="1" 
                          Margin="6,6,6,6">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="*" />
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>

                        <!-- Section Header -->
                        <Label Name="LabelOutputCriteria"
                                Content="{x:Static p:Resources.LabelOutputCriteria}"                           
                                Grid.Row="0" 
                                Margin="6,6,0,6" 
                                FontStyle="Italic" />

                        <!-- Top N -->
                        <StackPanel Orientation="Horizontal"
                                    Grid.Row="1"                                                                         
                                    Margin="24,6,6,6">
                            <Image Source="/Reckoning;component/Resources/bullet.gif" />
                            <Label Name="labelTopN1" 
                                   Content="{x:Static p:Resources.LabelAtLeast}" />
                            <ComboBox Name="comboBoxTopN" 
                                      ItemsSource="{Binding TopNItems}"
                                      SelectedItem="{Binding TopNThresh}" 
                                      ToolTip="{x:Static p:Resources.ToolTipTopN}"
                                      TabIndex="8" />
                            <Label Name="labelTopN2" 
                                   Content="{x:Static p:Resources.LabelTopWords}" />
                        </StackPanel>

                        <!-- Or -->
                        <Label Name="labelOr"
                               Grid.Row="2"  
                               Margin="100,0,6,0"
                               Content="{x:Static p:Resources.LabelOr}" />
                        

                        <!-- Percent -->
                        <StackPanel Orientation="Horizontal"
                                    Grid.Row="3"    
                                    Margin="24,6,6,6">
                            <Image Source="/Reckoning;component/Resources/bullet.gif" />
                            <Label Name="labelPercent1" 
                                    Content="{x:Static p:Resources.LabelComprisingAtLeast}" />
                            <ComboBox Name="comboBoxPercent" 
                                      ItemsSource="{Binding PercentItems}"
                                      SelectedItem="{Binding PercentThresh}" 
                                      ToolTip="{x:Static p:Resources.ToolTipPercent}"
                                      TabIndex="11" />
                            <Label Name="labelPercent2" 
                                   Content="{x:Static p:Resources.LabelPercentOfTotal}" />
                        </StackPanel>

                        <Grid Grid.Row="4"
                              Margin="24,6,6,6">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition Width="Auto" />
                            </Grid.ColumnDefinitions>
                            <CheckBox Name="checkBoxReferenceFile"
                                      Grid.Column="0"
                                      Content="{x:Static p:Resources.LabelReferenceFile}" 
                                      IsChecked="{Binding UseReferenceFile}"
                                      ToolTip="{x:Static p:Resources.ToolTipUseReference}"
                                      TabIndex="12"/>
                            <TextBox Name="textBoxReferenceFile" 
                                     Grid.Column="1"
                                     Text="{Binding ReferenceFilePath}" 
                                     Margin="6,0,6,0"
                                     HorizontalAlignment="Stretch" 
                                     MinWidth="200"
                                     IsEnabled="{Binding IsChecked, ElementName=checkBoxReferenceFile}"
                                     ToolTip="{x:Static p:Resources.ToolTipReference}"
                                     TabIndex="13" />
                            <Button Name="buttonReferenceFile" 
                                    Grid.Column="2"
                                    Content="{x:Static p:Resources.LabelBrowse}"
                                    HorizontalAlignment="Right"
                                    Padding="6,2,6,2"                                    
                                    IsEnabled="{Binding IsChecked, ElementName=checkBoxReferenceFile}"
                                    Click="ButtonReferenceFile_Click"
                                    ToolTip="{x:Static p:Resources.ToolTipBrowse}"
                                    TabIndex="14" />                            
                        </Grid>
                    </Grid>
                    <!-- Output Criteria -->

                </Grid>
                <!-- Options -->            
            </Expander>
        
            <!-- Go -->
            <StackPanel Orientation="Vertical"
                        Grid.Row="2"                       
                        Margin="0,6,0,6">
            
                <Separator />
        
                <Button Name="buttonCompute" Content="{x:Static p:Resources.LabelGo}"                
                        HorizontalAlignment="Center" 
                        Margin="0,6,0,6" Padding="6,2,6,2" 
                        Command="{Binding ComputeCommand}"                                
                        ToolTip="{x:Static p:Resources.ToolTipCompute}"
                        TabIndex="15" />
                
                <Separator />
            
            </StackPanel>

            <!-- Results -->
            <Expander Name="expanderResults" 
                      Header="{x:Static p:Resources.LabelResults}"
                      Grid.Row="3"
                      KeyboardNavigation.TabNavigation="Local"
                      TabIndex="16"
                      Margin="0,6,0,6">
        
                <Grid Name="gridResults"               
                      Margin="0,6,0,6">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>                
                        <RowDefinition Height="*"/>
                        <RowDefinition Height="Auto"/>
                    </Grid.RowDefinitions>

                    <Label Name="LabelReferenceFileStatus"
                           Grid.Row="0"
                           Content="{x:Static p:Resources.LabelNoReferenceData}"
                           Visibility="{Binding NoReferenceData, Converter={StaticResource bvc}}"
                           FontStyle="Italic" />
                
                    <StackPanel Orientation="Horizontal"
                                Grid.Row="1"                               
                                Margin="6,6,6,6">
                        <Label Name="labelTotalCountDesc"
                               Content="{x:Static p:Resources.LabelTotalCount}" />
                        <Label Name="labelTotalCount"
                               Content="{Binding TotalWordCount}" 
                               Margin="6,0,0,0" />            
                    </StackPanel>
            
                    <DataGrid Name="dataGridResults" 
                              ItemsSource="{Binding Results, NotifyOnTargetUpdated=True}" 
                              Grid.Row="2"
                              IsReadOnly="True" AutoGenerateColumns="False"                               
                              HorizontalGridLinesBrush="#FF938D8D" VerticalGridLinesBrush="#FF938D8D" 
                              AlternatingRowBackground="{DynamicResource {x:Static SystemColors.GradientInactiveCaptionBrushKey}}" 
                              Margin="6,6,6,6" 
                              ToolTip="{x:Static p:Resources.ToolTipResults}"      
                              MaxHeight="200"
                              TargetUpdated="DataGridResults_TargetUpdated"
                              TabIndex="17">
                        <DataGrid.Columns>
                            <DataGridTextColumn Header="{x:Static p:Resources.LabelRank}" 
                                                Binding="{Binding Rank, Mode=OneWay}" />
                            <DataGridTextColumn Header="{x:Static p:Resources.LabelWord}" 
                                                Binding="{Binding Word, Mode=OneWay}" />
                            <DataGridTextColumn Header="{x:Static p:Resources.LabelVariants}"
                                                Binding="{Binding Variants, Mode=OneWay}" />
                            <DataGridTextColumn Header="{x:Static p:Resources.LabelCount}" 
                                                Binding="{Binding Count, Mode=OneWay}" />
                            <DataGridTextColumn Header="{x:Static p:Resources.LabelPercent}" 
                                                Binding="{Binding PercentageOfTotal, Mode=OneWay, StringFormat='G4'}" />
                            <DataGridTextColumn Header="{x:Static p:Resources.LabelReferenceCount}" 
                                                Binding="{Binding ReferencePercentageOfTotal, Mode=OneWay, StringFormat='G4'}" />
                            <DataGridTextColumn Header="{x:Static p:Resources.LabelRatio}" 
                                                Binding="{Binding Ratio, Mode=OneWay, StringFormat='G4'}" />
                        </DataGrid.Columns>
                    </DataGrid>
               
                    <Button Name="ButtonSave"
                            Grid.Row="3"
                            Content="{x:Static p:Resources.LabelSave}"
                            HorizontalAlignment="Right" VerticalAlignment="Top"
                            Margin="6,0,6,0" Padding="6,2,6,2"
                            Command="{Binding SaveAsReferenceCommand}"
                            TabIndex="18" />
                </Grid>
            </Expander>
        
        </Grid>
    </ScrollViewer>
</Window>
